package com.ljm.common.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@SuppressWarnings("all")
public class BeanUtils extends org.springframework.beans.BeanUtils {
    protected static final Logger logger = LoggerFactory.getLogger(BeanUtils.class);

    public static <T> List<T> copyPropertiesByList(List<?> sourceList, Class<T> targetClass) {
        try {
            if (sourceList != null) {
                ArrayList<T> newList = new ArrayList<>();
                for (Object obj : sourceList) {
                    T target = targetClass.newInstance();
                    org.springframework.beans.BeanUtils.copyProperties(obj, target);
                    newList.add(target);
                }
                return newList;
            }
        } catch (Exception e) {
            logger.error("", (Throwable) e);
        }
        return Collections.emptyList();
    }
}
